<?php 
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Editor extends CI_Model { 
   
    function __construct()
     {
         parent::__construct();
     }
	function kind($name,$text)
	{
		$string='<script charset="utf-8" type="text/javascript" src="'.base_url().'statics/js/kindeditor/kindeditor.js"></script>';
		$string=$string.'<textarea id="'.$name.'" name="'.$name.'" cols="100" rows="8" style="width:690px;height:300px;">'.$text.'</textarea>';		$id="id:'".$name."'";
		$string=$string.'<script>        KE.show({           '.$id.',   allowFileManager : true     });</script>';
		return $string;
	}
      function shijian()
	  {
	  	date_default_timezone_set('PRC');
		$shijian=date("Y-m-d G:i:s");
		return $shijian;
	  } 
	  function show_list($table,$url,$uri,$start_row,$where,$order,$perpage=20)
		{
			//$perpage 每页显示数
			$table=$this->db->dbprefix($table);
			if($where!="")
			{
				$this->db->get_where($where);
			}
			if(!is_numeric($start_row))
			{
				$start_row=0;
			}
			$query=$this->db->get($table);
			$num=$query->num_rows();
			$conf['per_page']=$perpage;//每页显示数
			$conf['total_rows']=$num;//总共多少行
			$conf['base_url']=$url;
			$conf['uri_segment']=$uri;
			$this->load->library('pagination',$conf);
			$links=$this->pagination->create_links();
			
			$sqla="select * from $table  order by $order  desc limit ".$start_row.",".$perpage;
			//echo $sqla;
			$resa = $this->db->query($sqla);
			$res=$resa->result();		
			return array('res'=>$res,'total_rows'=>$conf['total_rows'],'links'=>$links,'per_page'=>$conf['per_page']);
		}
  }
